#include <stdio.h>
#include <unistd.h>
#include "ohos_init.h"
#include "pthread.h"

int secs1, secs2;
pthread_t tid1, tid2;

void *thread1_entry(void *arg)
{
    while (1)
    {
        printf("task1 demo\n");
        // 睡眠1s，让thread2运行
        sleep(1);
    }
    return 0;
}

void *thread2_entry(void *arg)
{
    while (1)
    {
        printf("task2 demo\n");
        // 睡眠1s，让threa12运行
        sleep(1);
    }
    return 0;
}
void demo_task()
{
    int err;
    printf("---posix thread---\n");
    // 创建thread1
    err = pthread_create(&tid1, NULL, thread1_entry, NULL);
	if(err != 0)
	{
		printf(" create new thread1 failed %d\n", err);
		return 0;
	}
    // 创建thread2
    err = pthread_create(&tid2, NULL, thread2_entry, NULL);
	if(err != 0)
	{
		printf(" create new thread2 failed %d\n", err);
		return 0;
	}
}

SYS_RUN(demo_task);
